<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>图像转像素 - 处理进度</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            min-height: 200px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        
        .container {
            text-align: center;
            padding: 20px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            backdrop-filter: blur(10px);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        }
        
        h1 {
            margin: 0 0 20px 0;
            font-size: 24px;
            font-weight: 300;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }
        
        .progress-container {
            width: 100%;
            height: 30px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 15px;
            overflow: hidden;
            margin: 20px 0;
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        .progress-bar {
            height: 100%;
            background: linear-gradient(90deg, #4CAF50, #45a049);
            width: 0%;
            transition: width 0.3s ease;
            border-radius: 15px;
            position: relative;
            overflow: hidden;
        }
        
        .progress-bar::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
            animation: shimmer 2s infinite;
        }
        
        @keyframes shimmer {
            0% { left: -100%; }
            100% { left: 100%; }
        }
        
        .progress-text {
            margin: 10px 0;
            font-size: 18px;
            font-weight: 500;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        }
        
        .status-text {
            margin: 15px 0;
            font-size: 14px;
            opacity: 0.9;
            min-height: 20px;
        }
        
        .details {
            margin-top: 20px;
            font-size: 12px;
            opacity: 0.8;
            line-height: 1.4;
        }
        
        .spinner {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 1s ease-in-out infinite;
            margin-right: 10px;
            vertical-align: middle;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        .complete {
            color: #4CAF50;
            font-weight: bold;
        }
        
        .error {
            color: #f44336;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎨 图像转像素处理中...</h1>
        
        <div class="progress-container">
            <div class="progress-bar" id="progressBar"></div>
        </div>
        
        <div class="progress-text" id="progressText">0%</div>
        
        <div class="status-text" id="statusText">
            <span class="spinner"></span>准备开始处理...
        </div>
        
        <div class="details" id="detailsText">
            等待处理参数...
        </div>
    </div>
    
    <script>
        // 更新进度条
        function updateProgress(percent, current, total, status, details) {
            const progressBar = document.getElementById('progressBar');
            const progressText = document.getElementById('progressText');
            const statusText = document.getElementById('statusText');
            const detailsText = document.getElementById('detailsText');
            
            // 更新进度条宽度
            progressBar.style.width = percent + '%';
            
            // 更新进度文本
            progressText.textContent = percent + '%';
            
            // 更新状态文本
            if (percent >= 100) {
                statusText.innerHTML = '<span class="complete">✅ 处理完成!</span>';
            } else if (status) {
                statusText.innerHTML = '<span class="spinner"></span>' + status;
            }
            
            // 更新详细信息
            if (details) {
                detailsText.textContent = details;
            } else if (current && total) {
                detailsText.textContent = `已处理: ${current}/${total} 个方块`;
            }
        }
        
        // 显示错误信息
        function showError(message) {
            const statusText = document.getElementById('statusText');
            statusText.innerHTML = '<span class="error">❌ ' + message + '</span>';
        }
        
        // 显示完成信息
        function showComplete(message, details) {
            const progressBar = document.getElementById('progressBar');
            const progressText = document.getElementById('progressText');
            const statusText = document.getElementById('statusText');
            const detailsText = document.getElementById('detailsText');
            const title = document.querySelector('h1');
            
            progressBar.style.width = '100%';
            progressText.textContent = '100%';
            statusText.innerHTML = '<span class="complete">✅ ' + message + '</span>';
            title.textContent = '🎉 处理完成!';
            
            if (details) {
                detailsText.textContent = details;
            }
        }
        
        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            // 通知Ruby端对话框已准备就绪
            if (typeof sketchup !== 'undefined') {
                sketchup.dialog_ready();
            }
        });
    </script>
</body>
</html>